/**
 * Created by liangqinli on 2016/12/23.
 */
import { fromJS, List } from 'immutable'
import { FETCH_HOME_LIST, HOME_LIST_SUCCESS, HOME_LIST_FAILED } from './actions'

const initialState = fromJS({
  isFetching: false,
  notes: [],
  err: ''
})

/* initialState.set('notes', List([1,2,3]));
console.log(initialState.get('notes')); */
export default function (state = initialState, action) {
  switch (action.type) {
    case FETCH_HOME_LIST: return state.set('isFetching', true)
    case HOME_LIST_SUCCESS: return state.set('notes', action.homeList).set('isFetching', false)
    case HOME_LIST_FAILED: return state.set('isFetching', false).set('err', action.err)
    default: return state
  }
}
